
#ifndef VOODOO_TEXTURE_HPP
#define VOODOO_TEXTURE_HPP

#include "Meta.hpp"

namespace VoodooShader
{
	class VOODOO_API Texture
	{
	public:
		Texture(void * texture, std::string name = "");
		Texture(unsigned int texture, std::string name = "");

	private:
		std::string mName;
		void * mTextureObject;
	};

	/**
	 * Texture format list (contained in a namespace for neatness).
	 */
	namespace TextureFormat
	{
		/**
		 * Texture formats for use by @ref Texture "Textures". These may not be 
		 * implemented by the underlying graphics API exactly as they are indicated 
		 * here, but the available components and sizes are guaranteed to be equal 
		 * to the indicated values. Further information on texture formats and depth
		 * may be found on the @ref texturesanddepth "texture formats page".
		 */
		enum TextureFormat
		{
			Unknown = 0,
			// Backbuffer formats
			//R5G6B6,
			RGB5,
			RGBA1,
			RGB8,
			RGBA8,
			RGB10A2,
			// Extended-depth texture formats
			RGBA16F,
			RGBA32F,
			// Depth-buffer formats
			D16,
			//D24S8,
			D32
		};
	}
}

/**
 * @page texturesanddepth Texture Formats and Depth Buffers
 *
 * @section textureformats Texture Formats
 * <div>
 * For most of these formats, DirectX and OpenGL equivalents are indicated
 * below, along with a notation indicating if the texture may be used as a
 * render-target or copied to and from.
 *
 * <table>
 *	<tr><th>Voodoo Format</th>	<th>DirectX Format</th>		<th>OpenGL Format</th>	<th>RT/Copy</td>	</tr>
 *	<tr><td>Unknown</td>		<td>D3DFMT_UNKNOWN</td>		<td>(unknown)</td>		<td>No</td>			</tr>
 *	<tr><td>RGB5</td>			<td>D3DFMT_X1R5G5B5</td>	<td>GL_RGB5</td>		<td>Yes</td>		</tr>
 *	<tr><td>RGB5A1</td>			<td>D3DFMT_A1R5G5B5</td>	<td>GL_RGB5_A1</td>		<td>Yes</td>		</tr>
 *	<tr><td>RGB8</td>			<td>D3DFMT_X8R8G8B8</td>	<td>GL_RGB8</td>		<td>Yes</td>		</tr>
 *	<tr><td>RGB8A1</td>			<td>D3DFMT_A8R8G8B8</td>	<td>GL_RGB8_A1</td>		<td>Yes</td>		</tr>
 *	<tr><td>RGB10A2</td>		<td>D3DFMT_A2R10G10B10</td>	<td>GL_RGB10_A2</td>	<td>Yes</td>		</tr>
 *	<tr><td>RGBA16F<sup>1</sup></td><td>D3DFMT_A16B16G16R16F</td><td>GL_RGBA16F</td><td>N/Y</td>		</tr>
 *	<tr><td>RGBA32F<sup>1</sup></td><td>D3DFMT_A32B32G32R32F</td><td>GL_RGBA32F</td><td>N/Y</td>		</tr>
 *	<tr><td>D16F</td>			<td>D3DFMT_A2R10G10B10</td>	<td>GL_DEPTH_COMPONENT16</td><td>N/Y-ish<sup>2</sup></td></tr>
 *	<tr><td>D32F</td>			<td>D3DFMT_A32B32G32R32F</td><td>GL_DEPTH_COMPONENT32</td><td>N/Y-ish<sup>2</sup></td></tr>
 * </table>
 * <em>Note <sup>1</sup>:</em> Floating-point texture formats (RGBA16F and RGBA32F) may not be supported on all
 * hardware.<br />
 * <em>Note <sup>2</sup>:</em> Depth textures suffer additional restrictions when used with the DirectX API. See
 * @ref depthbuffers "the depth buffers section" for more information.
 * </div>
 *
 * @section depthbuffers Depth Buffers
 * <div>
 *	DirectX 9 applies some stupid restrictions to depth textures. Adapters targetting this API should 
 *	work around these in some way and provide the Core with a valid texture containing the depth data. Due to
 *	the restrictions, the recommended format for this texture is R32F (D3DFMT_R32F). They should then create
 *	a texture using Core::CreateTexture with this alternate texture, and copy data from the depth-buffer to the
 *	readable texture each frame.
 * </div>
 * <div>
 *	This can be complicated and is always a pain to do, so it may be beneficial to use the prebuilt solution 
 *	in the generic Voodoo DirectX 9 adapter. This solution has been set up to use a D24S8 stencil buffer on
 *	the underlying hardware, while abstracting it to a R32F texture for shader access.
 *  This solution has been derived from work done in the Morrowind Graphics Extender project, and would 
 *	probably not exist without the efforts of phal and a few others from the Bethesda Softworks forum 
 *	(give them a hand for making this easy for the rest of us).
 * </div>
 */

#endif /*VOODOO_TEXTURE_HPP*/